package com.example.train_operate.controller;

import com.example.train_operate.entity.Network;
import com.example.train_operate.service.NetworkService;
import com.example.train_operate.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@CrossOrigin
@Api(tags = "网络设备检修任务接口")
@RequestMapping("/network")
public class NetworkController {

    @Resource
    private NetworkService networkService;

    /**
     * 添加网络设备检修任务
     * @param network
     * @return
     */
    @PostMapping("/addNetwork")
    @ApiOperation("添加网络设备检修任务")
    public Result addNetwork(@RequestBody Network network){
        return networkService.addNetwork(network);
    }

    /**
     * 通过网络设备检修任务id查询网络设备检修任务
     * @param networkId
     * @return
     */
    @GetMapping("/getNetworkById/{networkId}")
    @ApiOperation("通过网络设备检修任务id查询网络设备检修任务")
    public Result getNetworkById(@PathVariable Integer networkId){
        return networkService.getNetworkById(networkId);
    }

    /**
     * 修改网络设备检修任务
     * @param network
     * @return
     */
    @PutMapping("/updateNetwork")
    @ApiOperation("修改网络设备检修任务")
    public Result updateNetwork(@RequestBody Network network){
        return networkService.updateNetwork(network);
    }
}
